<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <link href="<?php echo base_url('public_source/css_source/center_contend.css')?>" rel="stylesheet" type="text/css">
        <script src="<?php echo base_url('public_source/javascript/change_image.js') ?>" type="text/javascript"></script>        
        <script src="<?php echo base_url('public_source/javascript/jquery-1.10.2.js') ?>" type="text/javascript"></script>      
        <script src="<?php echo base_url('public_source/javascript/jquery-ui.js');?>" type="text/javascript"></script>
        <link href="<?php echo base_url('public_source/javascript/jquery-ui.css');?>" rel="stylesheet" type="text/css"/>
        <script>
            $(document).ready(function(){	
                    
                    $(".love").click(function(){
                    $.ajax({
                            type: "POST",
                            url: "<?php echo site_url("home/add_like") ?>",
                            data: {id : $(this).attr("id")},
                            async: true,
                            success: function(kq){
                                var getData = $.parseJSON(kq);
                            if (getData.error === "OK")
                            {
                                alert("Đã thêm sản phẩm vào danh sách yêu thích");
                            }
                            else
                            {
                                alert(getData.error);
                            } }
                    });
                    return false;
                    });	
            });
        </script>
        <style>
            #jquery_link{
                margin-bottom: 10px;
            }
            .Info_Product{
                text-align: center;
                font-size: 11px;
                font-weight: normal;
                margin-top: 15px;
            }
            .Info_Product a{ text-decoration: none; color: #000}
            .Info_Product a:hover{ text-decoration: underline}
            .Price{ margin-top: 5px; text-align: center; font-weight: bold}
            .Buy_Button{height: 22px; width: 90px; color: #333; cursor: pointer; padding-left: 25px; padding-top: 4px; font-size: 12px; margin-top: 10px; font-weight: bold; margin-left: 30px; background-image: url(<% //php echo base_url("public_source/images_source/dathang.gif")%>); background-repeat: no-repeat}
            .num a, a:hover{text-decoration: none; color: #333}
            .Button {text-decoration: none}
            #ImageChoose span{
                position: absolute;
                background-color: #ffffff;
                padding: 5px;
                left: -1000px;
                border: 1px solid #cccccc;
                visibility: hidden;
                color: black;
                text-decoration: none;
            }
        </style>
    </head>
        <body>
            <table cellspacing="30px" width="575px" style="margin-left: 5px;">
                <?php 
                    $count = \count($lienquan);
                    $newLine = true;
                    for($i = 0; $i < 2; $i++)
                    {
                        if ($newLine == true)
                        {
                            echo "<tr>";
                            for($j = $i*3; $j < $i*3+3; $j++)
                            {
                                if ($j < $count)
                                {

                                    ?><td><a ID="ImageChoose" href="javascript:" onclick=change_image("<?php base_url("public_source/images_source/1.jpg")?>");> <?php echo '<img width="150px" height="110px" src="'.base_url($lienquan[$j]->hinh).'" alt="'.$lienquan[$j]->ten.'">';
                                    ?>
                                    <span> 
                                        <img src="<?php echo base_url($lienquan[$j]->hinh)?>" width="500px" height="400px">
                                    </span>
                                    <?php 
                                    echo '</a>';
                                    echo '<div class="Info_Product"><a href="'. site_url("home/infomationProduct/".$lienquan[$j]->id) .'" title="'.$lienquan[$j]->ten.'">'.$lienquan[$j]->ten.'</a>';
                                    if ($lienquan[$j]->fldStatus == 1)
                                        echo '<a href=""><img width="29px" height="19px" src="'.base_url("public_source/images_source/icon_km.gif").'"></a>';
                                    if ($lienquan[$j]->fldStatus == 2)
                                        echo '<a href=""><img width="29px" height="19px" src="'.base_url("public_source/images_source/icon_new.gif").'"></a>';
                                    echo '<a id="'.$lienquan[$j]->id.'" class="love" style="float: right; cursor: pointer;" title="Thêm vào yêu thích"><img src="'.base_url("public_source/images_source/green-plus-sign-md.png").'" width="15px" height="15px"></a>';
                                    echo '</div>';
                                    echo '<div class="Price">'.number_format($lienquan[$j]->gia,0,'.','.').' VNĐ</div>';
                                    echo '<a class="Button" href="'.site_url("home/update_my_cart").'?id='.$lienquan[$j]->id.'&name='.$lienquan[$j]->ten.'&cost='.$lienquan[$j]->gia.'&url='.$lienquan[$j]->hinh.'"><div class="Buy_Button">Mua hàng</div></a>';
                                    echo '</td>';
                                }
                                else
                                    $newLine = false;
                            }
                            echo "</tr>";
                        }
                    }
                ?>
            </table>
        </body>
</html>